package com.wish.g1.house.controller;


import com.wish.g1.house.entity.Metro;
import com.wish.g1.house.entity.Region;
import com.wish.g1.house.service.IMetroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 地铁表 前端控制器
 * </p>
 *
 * @author Dragon
 * @since 2022-11-18
 */
@RestController
@RequestMapping("/metro")
public class MetroController {

    @Autowired
    IMetroService iMetroService;


    /**
     * 根据城市查询地铁
     * @param id
     * @return
     */
    @GetMapping("/queryMetroListById/{id}")
    public List<Metro> queryMetroListById(@PathVariable("id") Integer id){
        ArrayList<Metro> list = new ArrayList<>();
        List<Metro> list1 = iMetroService.list();
        for (Metro metro : list1) {
            if(metro.getCity() == id){
                list.add(metro);
            }
        }
        System.out.println("---------------------------------------------------"+list);
        return list;
    }


}
